package chapter67;

/*
 * 父类：宠物类
 */

public abstract class Pet {
	private String name = "无名氏"; //宠物的名字
	int health = 88; //宠物的健康值，健康值在0-100之间
	private int love = 2; //宠物的亲密度，亲密度在0-100之间
	
	public Pet(){
		
	}
	
	public Pet(String name){
		this.name = name;
	}
	
	// 给name赋值
		public void setName(String name) {
			this.name = name;
		}

		// 获取name值
		public String getName() {
			return this.name;
		}

		// 给health赋值
		public void setHealth(int health) {
			if (health <= 0 || health > 100) {
				System.out.println("健康值输入有误");
				this.health = 60;
			} else {
				this.health = health;
			}
		}

		// 获取health值
		public int getHealth() {
			return this.health;
		}

		// 给love赋值
		public void setLove(int love) {
			if (love <= 0 || love > 100) {
				System.out.println("亲密度输入有误");
				this.love = 60;
			} else {
				this.love = love;
			}
		}

		// 获取love值
		public int getLove() {
			return this.love;
		}
		
		
		//输出宠物的信息
		public void showInfo() {
			System.out.println("宠物的自白：\n我的名字叫：" + this.getName() + "，我的健康值是" + this.getHealth() + "，我与主人的亲密度是" + this.getLove());
		}
		
		//方法：去医院看病
		public abstract void toHospital();
		
		//给宠物喂食
		public abstract void toEat();
}
